<ul class="nav nav-tabs">
	<li ng-class="{'active':pagedata.op=='app_update'}"><a href="javascript:;">更新官方应用</a></li>
</ul>
<div class="form-horizontal form" ng-if="pagedata.op=='app_update'">
<div class="panel panel-info" ng-init="pagedata.update()">
	<div class="panel-body">
		<div id="show_message"></div>
		
	</div>
</div>
</div>
<script>
	scope.pagedata.update=function(){
		//console.log(scope.pagedata);return false;
		scope.pagedata.add_message('准备更新官方应用...');
		if(scope.pagedata.plugins){
			scope.pagedata.add_message('准备更新官方插件...');
			$.each(scope.pagedata.plugins,function(index,plugin){
				scope.pagedata.add_message('准备更新官方插件:'+plugin.title+'...');
				var post={'plugin':'core','action':'cloud.module','op':'update','id':plugin.id};
				var callback=function(res){
					if(res=='更新成功！'){
						scope.pagedata.add_message('插件'+plugin.title+'更新成功！');
					}else{
						scope.pagedata.add_message('插件'+plugin.title+'更新失败！');
					}
				}
				scope.ajax(post,'',callback,true);
			});
		}
		if(scope.pagedata.pc_blocks){
			scope.pagedata.add_message('准备更新官方pc组件...');
			$.each(scope.pagedata.pc_blocks,function(index,plugin){
				scope.pagedata.add_message('准备更新官方pc页面组件:'+plugin.title+'...');
				var post={'plugin':'core','action':'cloud.pc_blocks','op':'update','id':plugin.id};
				var callback=function(res){
					if(res=='更新成功！'){
						scope.pagedata.add_message('pc页面组件'+plugin.title+'更新成功！');
					}else{
						scope.pagedata.add_message('pc页面组件'+plugin.title+'更新失败！');
					}
				}
				scope.ajax(post,'',callback,true);
			});
		}
		if(scope.pagedata.mobile_blocks){
			scope.pagedata.add_message('准备更新官方手机页面组件...');
			$.each(scope.pagedata.mobile_blocks,function(index,plugin){
				scope.pagedata.add_message('准备更新官方手机页面组件:'+plugin.title+'...');
				var post={'plugin':'core','action':'cloud.mobile_blocks','op':'update','id':plugin.id};
				var callback=function(res){
					if(res=='更新成功！'){
						scope.pagedata.add_message('手机页面组件'+plugin.title+'更新成功！');
					}else{
						scope.pagedata.add_message('手机页面组件'+plugin.title+'更新失败！');
					}
				}
				scope.ajax(post,'',callback,true);
			});
		}
		scope.pagedata.add_message('官方应用更新完成！');
		setTimeout(function(){
			scope.message('官方应用更新成功！','','info');
		},1000);
	}
	scope.pagedata.add_message=function(msg){
		msg='<div>'+msg+'</div>';
		$('#show_message').append(msg);
	}
</script>
